Transactional compare-and-discard instruction

ABSTRACT

An apparatus comprising: processing circuitry to process threads of data processing; and transactional memory support circuitry to support execution of a transaction within a thread processed by the processing circuitry. In response to a transactional compare-and-discard instruction executed within a given transaction, specifying a target address and a compare value, the processing circuitry loads a target data value from a memory location corresponding to the target address; sets at least one condition status indication depending on a result of comparing the target data value and the compare value; and discards the target data value without adding the target address to a working set of addresses tracked for the given transaction. This is useful for enabling thread level speculation to be implemented on a transactional memory architecture.

The present technique relates to the field of data processing. Moreparticularly, it relates to transactional memory.

A data processing system may execute a number of threads of dataprocessing. Sometimes, the threads may need to access a shared resourceand the nature of the data processing operations may be such that once athread starts interacting with the shared resource, it may be necessaryfor a set of operations to complete atomically using the resourcewithout another thread accessing the resource in the meantime.

One technique for handling this conflict between threads may be to uselocks to control exclusive access to at least one target resource. Forexample, when one thread starts accessing data in a particular addressregion, the thread may set a lock variable to claim ownership of thelock, and then while the lock owning thread has ownership of the lock,other threads checking the lock variable may determine that the lock isalready claimed and so may not enter the section of code which interactswith that address region. Such a lock-based approach can be seen aspessimistic in that each thread by default assumes that it cannot enterthe section of code which access the shared resource because a conflictwith another thread may occur, unless it has ownership of the lockguaranteeing that no conflict can occur. However, often a lockidentifier may control exclusive access to a number of resources (e.g. arange of addresses), and so it is not guaranteed that if one thread isaccessing certain resources within the set of resources protected by thelock variable, another thread will definitely access the same resource.Hence, a lock-based approach may, in cases where conflicts betweenthreads are rare, lead to a loss of performance because threads mayunnecessarily be waiting for the locks to be released before enteringthe critical section of code which uses the shared resource.

A more optimistic approach for handling conflicts between threadsaccessing shared resources can be to use transactional memory support. Adata processing system may have circuitry to support execution of atransaction within a thread of data processing by the processingcircuitry. The transaction may be those instructions of the thread whichare executed between a transaction start instruction marking thebeginning of the transaction and a transaction end instruction markingthe end of the transaction. Between the transaction start and endinstructions, the processing circuitry may speculatively execute theintervening instructions and prevent commitment of the results of thosespeculatively executed instructions until the transaction endinstruction is reached. Occurrence of an abort event following executionof the transaction start instruction (but before the transaction endinstruction is reached) may result in the transaction being aborted andthe speculative results being discarded. There may be a number ofreasons for aborting a transaction, but one reason may be a detectedconflict with a memory access made by another thread. Hence, with thisapproach each thread may optimistically start processing the criticalsection of code assuming that no conflicts with other threads willoccur, and then if the end of the critical section is reached withoutany conflict being detected the results of the transaction can becommitted. In cases where conflict is rare, using transactional memorysupport can improve performance by allowing more threads to concurrentlyprocess their critical sections of code.

At least some examples provide an apparatus comprising: processingcircuitry to process threads of data processing; and transactionalmemory support circuitry to support execution of a transaction within athread processed by the processing circuitry, the transaction comprisinginstructions of the thread executed speculatively between a transactionstart instruction and a transaction end instruction, for which theprocessing circuitry is configured to prevent commitment of results ofthe speculatively executed instructions until the transaction endinstruction is reached, the transactional memory support circuitrycomprising conflict detection circuitry to trigger an abort of thetransaction in response to detecting a conflicting access from anotherthread to one of a working set of addresses tracked for the transaction;in which: in response to a transactional compare-and-discard instructionexecuted within a given transaction, the transactionalcompare-and-discard instruction specifying a target address and acompare value, the processing circuitry is configured to: load a targetdata value from a memory location corresponding to the target address;set at least one condition status indication depending on a result ofcomparing the target data value and the compare value; and discard thetarget data value without adding the target address to the working setof addresses for the given transaction.

At least some examples provide a data processing method comprising:executing a transaction comprising instructions of a thread executedspeculatively between a transaction start instruction and a transactionend instruction, for which the processing circuitry is configured toprevent commitment of results of the speculatively executed instructionsuntil the transaction end instruction is reached, detecting conflictingaccesses from another thread to one of a working set of addressestracked for the transaction, and when a conflicting access is detected,aborting the transaction; and in response to a transactionalcompare-and-discard instruction specifying a target address and acompare value, which is executed within the transaction: loading atarget data value from a memory location corresponding to the targetaddress; setting at least one condition status indication depending on aresult of comparing the target data value and the compare value; anddiscarding the target data value without adding the target address tothe working set of addresses for the given transaction.

At least some examples provide a computer program for controlling a hostdata processing apparatus to provide an instruction executionenvironment for execution of threads of data processing; the computerprogram comprising: processing program logic to process threads of dataprocessing; and transactional memory program logic to support executionof a transaction within a thread processed by the processing programlogic, the transaction comprising instructions of the thread executedspeculatively between a transaction start instruction and a transactionend instruction, for which the processing program logic is configured toprevent commitment of results of the speculatively executed instructionsuntil the transaction end instruction is reached, the transaction memoryprogram logic comprising conflict detection program logic to trigger anabort of the transaction in response to detecting a conflicting accessfrom another thread to one of a working set of addresses tracked for thetransaction; in which: in response to a transactionalcompare-and-discard instruction executed within a given transaction, thetransactional compare-and-discard instruction specifying a targetaddress and a compare value, the processing program logic is configuredto: load a target data value from a memory location corresponding to thetarget address; set at least one condition status indication dependingon a result of comparing the target data value and the compare value;and discard the target data value without adding the target address tothe working set of addresses for the given transaction.

A storage medium may store the computer program. The storage medium maybe a non-transitory storage medium.

Further aspects, features and advantages of the present technique willbe apparent from the following description of examples, which is to beread in conjunction with the accompanying drawings, in which:

FIG. 1 schematically illustrates an example of a data processingapparatus having transactional memory support circuitry;

FIG. 2 shows an example of processing a transaction using transactionalmemory resources;

FIG. 3 shows an example of a status register storing condition statusindications and a table showing different conditions that can beindicated by the condition status indications;

FIG. 4 shows an example of a multi-core processing system;

FIG. 5 shows an example of performing thread level speculation on amulti-core system supporting transactional memory;

FIG. 6 schematically illustrates an example of a transactionalcompare-and-discard instruction;

FIG. 7 is a flow diagram showing a method of processing transactionsusing transactional memory support circuitry;

FIG. 8 is a flow diagram showing a method of processing a transactionalcompare-and-discard instruction executed within a transaction;

FIGS. 9 and 10 show examples of bus protocol messages used to requestloading of data from a memory system; and

FIG. 11 shows a simulator example that may be used.

A data processing apparatus may have processing circuitry which hastransactional memory support circuitry to support execution of atransaction within a thread of data processing processed by theprocessing circuitry. The transaction comprises instructions of thethread which are executed speculatively between a transaction startinstruction and a transaction end instruction, for which the processingcircuitry may prevent commitment of results of the speculativelyexecuted instructions of the transaction until the transaction endinstruction is reached, and may abort processing of the transaction whenan abort event occurs before reaching the transaction end instruction.The transactional memory support circuitry may comprise conflictdetection circuitry to trigger an abort of the transaction in responseto detecting a conflicting access from another thread to one of aworking set of addresses tracked for the transaction.

In the techniques discussed below the processing circuitry supports atransactional compare-and-discard instruction which specifies a targetaddress and a compare value. In response to the transactionalcompare-and-discard instruction being executed within a giventransaction, the processing circuitry may load a target data value froma memory location (e.g. a cache location or system memory location)corresponding to the target address, set at least one condition statusindication depending on a result of comparing the target data value andthe compare value, and discard the target data value without adding thetarget address to the working set of addresses tracked for the giventransaction.

This approach is counterintuitive since normally one would expect thatany load of data from memory within a transaction should have thecorresponding address tracked within the transaction's working set, sothat if other threads write to the same address while the transaction isin flight then the transaction can be aborted to avoid the transactionusing a potentially stale (out-of-date) value from the required address.

However, the inventors recognised that a transactionalcompare-and-discard instruction which executes a comparison between avalue read from memory and a compare value without adding the targetaddress to the working set of addresses for the transaction can beparticularly useful for supporting use of transactional memory inexploiting thread level speculation. Some program loops may include anumber of iterations in which each iteration accesses certain memoryaddresses but it is not known statically at compile time whether therewill be aliasing between the addresses accessed by one iteration and theaddresses accessed by another iteration. A conservative approach toexecuting such loops may be to assume that there could be a dependencybetween loops, and hence to execute each iteration sequentially with agiven iteration only being executed once the preceding iteration iscomplete. In thread level speculation, it is assumed that such aliasingbetween different iterations may be sufficiently rare that performancecan be improved by speculatively executing multiple iterations of theloop in parallel using separate threads of data processing. With threadlevel speculation, the threads corresponding to multiple iterations caneach be executed simultaneously, and a runtime check of whether theaddresses accessed by one iteration conflict with addresses accessed byanother iteration may be performed and some threads can be cancelled andreexecuted later if there is an address conflict between threadsprocessed in parallel. Transactional memory could be used to supportsuch thread level speculation, since the address tracking and abortmechanism of transactional memory could be used to check for addresshazards between the threads corresponding to different iterations of theprogram loop.

However, to use transactions to support thread level speculation, theremay be a need to ensure that the transactions corresponding to eachiteration of the loop are committed in an order corresponding to theorder of the loop iterations of the original program loop. Typicaltransactional memory architectures have no way of enforcing a certainorder in which transactions are committed relative to othertransactions. Instead most transactional memory architectures assumethat each transaction is entirely independent. The transactionalcompare-and-discard instruction discussed above can support the use ofthread level speculation in a transactional memory system. Thetransactional compare-and-discard instruction may be used to check avariable stored in memory which tracks the most recently committediteration of the loop being parallelised using thread level speculation.As the transactional compare-and-discard instruction sets the conditionstatus indication based on the result of the comparison, this enablesother instructions of the transaction to check whether the transactionsfor any earlier iterations of the loop have committed.

As the target data value is discarded without adding the target addressto the working set of addresses, this means that even when the sharedvariable indicating the most recently committed iteration of the loop isread/written by multiple threads, such apparent address conflict wouldnot trigger an abort of any of the transactions. This is useful becauseif transactions were aborted when they access a shared variable definingwhich iterations have committed, then this would effectively result inall of the transactions being serialised so that they are executedsequentially, hence eliminating the very advantage of using thetransactions to support thread level speculation in the first place. Thetransactional compare-and-discard instruction avoids this problembecause the target address accessed in the load is not added to theworking set of addresses and so transactions can continue to be executedspeculatively without an abort even when one transaction writes to thesame shared variable as read by another transaction. The architecturalsupport for the transactional compare-and-discard instruction enablestransactions to be used to support transactional memory in a way whichis less hardware-intensive than alternative ways of enabling thisfunctionality.

It will be appreciated that thread level speculation is just onefunctionality which could benefit from the use of a transactionalcompare-and-discard instruction, and in practice once architecturalsupport for this instruction is provided then programmers or compilersmay find other functions which could usefully be performed for this typeof instruction. Hence, while the transactional compare-and-discardinstruction provides particular architectural benefits to supportingthread levels speculation, the instruction could also be used for otherpurposes.

The compare value could be specified in different ways by thetransactional compare-and-discard instruction. In some cases the comparevalue could be specified as an immediate value in the instructionencoding of the transactional compare-and-discard instruction.

However, it can be particularly useful to provide an architecture wherethe transactional compare-and-discard instruction identifies a comparevalue using a source register. In practice, when this type ofinstruction is used for supporting thread level speculation, differentthreads corresponding to different loop iterations may need to comparethe value loaded from memory against different values of the comparevalue depending on the particular iteration which that threadrepresents. By using a source register to define the compare value, thismakes it simpler to write a common set of instructions to be executedfor different iterations in respective transactions.

In response to the transactional compare-and-discard instruction, theprocessing circuitry may discard the targeted value without writing thetarget data value to an architectural register of the processingcircuitry. Hence, the target data value read from memory is not madeaccessible to the software as a result of executing the transactionalcompare-and-discard instruction. Instead, the transactionalcompare-and-discard instruction only provides a limited access to thetarget data value for the purpose of comparing it with the compare valueand setting at least one condition status indication depending on theresult of the comparison.

By limiting the extent to which the software gains access to the targetdata value within the architectural registers, this makes it less likelythat the compare-and-discard instruction could be used inappropriatelyby a programmer or a compiler to attempt within a transaction access toa data value which could potentially be accessed by other threads. Incontrast, if a general non-transactional load instruction was provided,which could be executed within a transaction to write a target valueloaded from memory into an architectural register (without tracking thecorresponding address in the working set of addresses for the giventransaction), this would be more open to misuse by a programmer orcompiler as it may be that addresses which should really be tracked forconflicts with other threads are inappropriately accessed by thenon-transactional load.

In some architectures, the transactional compare-and-discard instructionmay be restricted to only execute successfully when a transaction isin-flight. Hence, if a transactional compare-and-discard instruction isattempted to be executed when not within a transaction, an instructiondecoder could treat the transactional compare-and-discard instruction asan undefined instruction and trigger an exception to cause the undefinedinstruction to be handled by an exception handler.

Alternatively, the transactional compare-and-discard instruction couldalso be supported when not executing instructions within a transaction.In this case the transactional compare-and-discard may trigger theprocessing circuitry to load a data value from memory and compare theloaded data value with a compare value specified by the instruction.

The architecture supporting the transactional compare-and-discardinstruction may also support at least one form of conditionalinstruction which specifies a test condition. The conditionalinstruction controls the processing circuitry to perform a processingoperation conditional on the at least one condition status indicationmeeting the test condition. For example, the architecture may require adedicated condition status register to be provided for storing one ormore condition flags representing the condition status indication. Forexample, the condition flags may represent properties of previousprocessing results, such as whether a result was negative, involved anoverflow, involved a carry, or was 0. The at least one condition statusindication may be the same indication that is also set by other forms ofcondition setting instruction, other than the transactionalcompare-and-discard instruction.

The transactional memory support circuitry may, in addition to theconflict detection circuitry, also include other elements. For examplethe transactional memory support circuitry could include speculativeresult storage circuitry to store results of speculatively executedinstructions for at least one transaction, and/or restoration statestorage circuitry to store architectural state captured in response tothe transaction start instruction of a transaction, which can berestored if the transaction is aborted. For example, the speculativeresult storage circuitry could buffer results of store instructionsuntil the transaction is committed in response to the transaction endinstruction, so that the speculatively executed store instructionswithin the transaction do not pollute the memory system until it isknown that the transaction can be committed. The restoration statestorage circuitry could for example include registers within a registerbank for retaining a checkpoint of state present at the start of thetransaction in case the state needs to be rewound to that earlier pointof execution when the transaction is aborted. Alternatively, therestoration state could be maintained using register renaming to trackold checkpointed architectural state within the same register file asthe registers storing the current architectural state.

Another possible reason for aborting the transaction may be if thetransactional memory support circuitry runs out of resources so that itis no longer possible to guarantee that the transaction will proceedcorrectly without conflict. For example, if the number of speculativeresults to be stored in the speculative result storage circuitry exceedsthe capacity available within the storage provided, then a transactioncould be aborted.

On aborting a transaction, it may be up to software to determine whetherto try to execute the transaction again, or to use a non-transactionalfallback path instead (e.g. using locks and load/store-exclusiveinstructions). However, the micro-architecture of the processingcircuitry could provide hints to indicate a possible reason of the abortof the transaction, which could be used by the software to determinewhether it is worth attempting to execute the transaction again or touse the fallback path (e.g. if the cause of the abort is such that anyfuture attempt would be likely to fail).

As discussed above, the transactional compare-and-discard instructionmay be used to perform thread level speculation in which two or morethreads of processing are executed, with each thread corresponding to arespective iteration of a program loop and each thread comprising atleast one transaction. In such a use case, the transactionalcompare-and-discard instruction may specify as the target address anaddress of a loop iteration commit variable for tracking process incommitting transactions for the plurality of iterations of the programloop. Each thread may include, within a transaction, one or moreinstructions for determining whether to abort the transaction based onwhether the at least one condition status indication set by thetransactional compare-and-discard instruction satisfies a testcondition. For example each thread may include, within a transaction, awhile loop which uses the transactional compare-and discard instructionto compare the loop iteration commit variable against a compare valuespecific to the current loop iteration, tests the resulting conditionstatus indication(s) using a conditional instruction, and thenconditionally branches back to the start of the loop if the conditionstatus indication does not yet indicate that the current loop iterationis ready to commit. When the current loop iteration is ready to commit,program execution may proceed to a transaction end instruction to committhe results of the entire transaction.

The processing circuitry may interact with the memory system using busprotocol messages defined according to a particular bus protocol. Inresponse to the transactional compare-and-discard instruction, theprocessing circuitry may trigger issue of a first bus protocol messagefor requesting the load of the target data value from a memory system.The first bus protocol message may comprise an indication whichdistinguishes the bus protocol message from a second bus protocolmessage issued for other types of instruction requiring a load of a datavalue from memory. For example, the first bus protocol message could beof a different message type to the second bus protocol message, or couldbe of the same message type as the second bus protocol message but mayspecify a parameter or control flag which distinguishes the first busprotocol message from the second bus protocol message. It can be usefulfor the bus protocol messages to distinguish loads triggered by atransactional compare-and-discard instruction from loads triggered byother types of instructions, because for the transactionalcompare-and-discard instruction some operations (which may otherwise berequired for general load operations to ensure data coherency and/ormanage conflicts between transactions executing on different processingelements) may not be needed for a load triggered by a transactionalcompare-and-discard instruction, which can enable some performanceimprovements.

For example, in a system comprising a further processing element alsocomprising the transactional memory support circuitry, in response toreceipt of the first bus protocol message or a further bus protocolmessage triggered by the first bus protocol message (e.g. a snoopmessage triggered by an interconnect in response to the first busprotocol message), then if the further processing element is currentlyexecuting a transaction for which the target address is part of a writeset of addresses tracked for that transaction, it is not necessary toabort the transaction on the further processing element. Instead, thetransaction at the further processing element can be permitted tocontinue unaborted, until it reaches its transaction end instruction(unless any other cause for an abort is detected). This would becounter-intuitive since normally one would expect that for mutualexclusion it is necessary to abort a transaction with an address in itswrite set when another transaction reads the same address, to ensurethat a write to an address by one transaction cannot commit after thesame address has been read by another transaction.

However, in the expected use case for the transactionalcompare-and-discard instruction, the instruction may be used within awhile loop which spins until a shared iteration tracking variable hasreached the required value, so it is not a problem if the loadassociated with the transactional compare-and-discard instruction isserviced using an out of date value which has already been written to byanother transaction executing on a different processing element. Even ifthe value loaded by the transactional compare-and-discard instruction isout of date, in this case the while loop would simply spin for someadditional cycles until the other transaction is committed and theupdated value can then be returned on a subsequent pass through thewhile loop. As aborting the transaction at the further processingelement would in any case simply result in the old value (not updated bythe aborted transaction) being returned, the effect at the firstprocessing element executing the transactional compare-and-discardinstruction is the same, but by not aborting the transaction at thefurther processing element performance can be improved since it is notnecessary to restart the transaction again later.

Also, as it is not always necessary to provide the most up to date valuewhen servicing the load associated with the transactionalcompare-and-discard instruction, this means the memory system (orinterconnect) may be able to service the load faster by providing a(potentially out of date) value from a cache with lower access latencythan if a value which is guaranteed to be the most up to date value hadto be obtained, which might require longer access latency in some cases.

Hence, providing a bus protocol with a message format whichdistinguishes loads triggered by a transactional compare-and-discardinstruction from other types of load can be useful to enable performanceimprovements.

A corresponding computer program may be provided for controlling a hostdata processing apparatus to provide an instruction executionenvironment for execution of threads of data processing, the computerprogram comprising processing program logic to process threads of dataprocessing and transactional memory program logic to support executionof a transaction within a thread processed by the processing programlogic (in a similar way to the support for transactions discussed abovefor a hardware embodiment). The transactional memory program logic maycomprise conflict detection program logic for triggering a transactionto be aborted when a conflicting access from another thread to one ofthe working set of addresses tracked for the transaction is detected.The program logic of the computer program may respond to the executionof a transactional compare-and-discard instruction in a similar way tothe corresponding processing circuitry as discussed above.

Hence, a computer program may be provided which presents, to softwareexecuting above the computer program, a similar instruction environmentto that which would be provided by an actual hardware apparatus havingthe features discussed above, even though there may not be any actualhardware providing these features in the host computer executing thecomputer program. Instead the computer program, which may for example bea simulator or a virtual machine, may emulate the functionality of thehardware architecture by providing program logic (such as sets ofinstructions or data structures) which enables a generic host dataprocessing apparatus to execute code intended for execution on anapparatus with transactional memory support, in a manner compatible withthe results that would be achieved on the apparatus with transactionalmemory support.

The computer program may be stored on a storage medium. The storagemedium may be a non-transitory storage medium.

FIG. 1 illustrates an example of a data processing apparatus comprisinga processor core 2 with hardware transactional memory (HTM) support. Thecore 2 has processing logic 4 for executing instructions to carry outdata processing operations. For example the processing logic 4 mayinclude execution units for executing various types of processingoperations, such as an arithmetic/logic unit (ALU) for carrying outarithmetic or logical operations such as add, multiply, AND, OR, etc.; afloating-point unit for performing operations on floating pointoperands; or a vector processing unit for carrying out vector processingon vector operands comprising multiple data elements. A set ofarchitectural registers 6 is provided for storing operands for theinstructions executed by the processing logic 4 and for storing theresults of the executed instructions. The architectural registers 6include a status register 7 for storing at least one status value (e.g.a condition flag) indicating a property of a result of a previouslyexecuted instruction. An instruction decoder 8 decodes instructionsfetched from an instruction cache 10 to generate control signals forcontrolling the processing logic 4 or other elements of the dataprocessing apparatus 2 to perform the relevant operations. A load/storeunit 12 is also provided to perform load operations (in response to loadinstructions decoded by the instruction decoder 8) to load a data valuefrom a data cache 14 or main memory 16 into the architectural registers6, and store operations (in response to store instructions decoded bythe instruction decoder 8) to store a data value from the architecturalregisters 6 to the data cache 14 or memory 16.

The processor core 2 also has transactional memory support circuitry 20which provides various resources for supporting hardware transactionalmemory (HTM). The HTM resources in the transactional memory supportcircuitry 20 may include for example speculative result storage 22 forstoring speculative results of transactions, address tracking circuitry24 for tracking a working set of addresses accessed by a transaction,conflict detection circuitry 26 for detecting conflicts between dataaccesses made by a transaction and data accesses made by other threads,so that a transaction can be aborted when a conflict is detected, andrestoration state storage circuitry 28 for storing a snapshot of thearchitectural state data from the architectural registers 6 at the startof a transaction, so that this state can be restored to overwrite thespeculative results of the transaction when a transaction is aborted. Insome examples, the tracking of the working set of addresses may includeseparate tracking of a read set of addresses (representing addressesread by the transaction), and a write set of addresses (representingaddresses written to by the transaction). For example, the read/writesets of addresses could be tracked by setting flags in a cacheindicating whether associated cache lines are part of the read set orwrite set respectively for a given transaction.

Also the resources may include a nesting depth register 30 for storing anesting depth value tracking a level of nesting of transactions. It canbe useful for a programmer or compiler to be able to define nestedtransactions (where a second transaction start instruction isencountered after a first transaction start instruction, but before thetransaction end instruction corresponding to the first transaction startinstruction). This can be useful to ensure that a critical section ofcode is treated atomically even if there is a branch into a part of thecode beyond the first transaction start instruction. However, to avoidhaving to capture multiple checkpoints of architectural state in thespeculative result storage, some microarchitectures may effectivelyignore the “inner” transactions of a nested set of transactions, andonly capture a checkpoint of an architectural state in response to thevery first transaction start instruction. Any subsequent transactionstart instruction arising before the transaction end instruction mayeffectively be ignored, except that the nesting depth register 30 may beincremented to track how many transaction start instructions have beenencountered, so that on encountering the transaction end instructions,the micro-architecture can track which transaction end instructionrelates to the outer transaction of the nested set of transactions.Hence, when encountering a transaction end instruction, if the nestingdepth is one or more, then the transaction end instruction is ignored,and if the nesting depth is zero (indicating that the transaction is theouter transaction of a nested set), the transaction may be committed.

FIG. 2 shows an example of executing a transaction within a given threadusing the transactional memory support circuitry 20 and the processinglogic 4. A transaction is a section of program code which is bounded bya transaction start instruction (tstart) and a transaction endinstruction (tcommit). As shown in FIG. 2, in response to thetransaction start instruction the current architectural state in thearchitectural registers 6 is captured and stored in the restorationstate storage circuitry 28. The processing logic 4 begins to performspeculative execution of the subsequent instructions following thetstart instruction, and as these instructions are executed, theaddresses accessed by those instructions are tracked by the addresstracking circuitry 24, and the conflict detection circuitry 26 detectsconflicts between the tracked addresses and addresses of memory accessesmade for other threads. At least some speculative results of theinstructions within the transaction are stored within the speculativeresult storage circuitry 22. For example the value stored to the cacheor to memory in response to a store instruction STR may be held in thespeculative result storage 22 while the transaction remains pending. Ifthe transaction end instruction (tcommit) is reached without an abortevent occurring in the meantime, then in response to the transaction endinstruction the speculative results are committed. On committing thetransaction, any results stored in the speculative result storage 22 forthat thread may be written to the data cache 14 or memory 16 and therestoration state 28 can be discarded or permitted to be overwritten asit is no longer needed to rewind architectural state to the point beforethe transaction start instruction was encountered.

On the other hand, if an abort event occurs, for example when a conflictis detected by the conflict detection circuitry 26 when another threadaccesses an address already accessed by the transaction, then an abortof the transaction is triggered and the restoration state from therestoration state storage 28 is restored to the architectural registers6. Other causes of an abort event could for example include execution ofan instruction which is not allowed to be executed within a transaction,insufficient resource within the speculative result storage 22 or anaddress tracking circuitry 24 for handling the speculative results oraddresses required by a given transaction, or an interrupt beingreceived during the transaction.

FIG. 3 schematically illustrates an example of condition statusindications 40 indicated in the status register 7. The instruction setarchitecture supported by the instruction decoder 8 may include a numberof types of condition setting instruction, which could be an arithmeticor logical instruction for performing an arithmetic/logical operationand setting the condition status 40 based on a property of the result,or a dedicated comparison instruction for comparing two values andsetting the condition status indications 40 based on the result of thecomparison. The comparison instruction may effectively be a subtractioninstruction which subtracts one of the values to be compared from theother, and sets the condition flags 40 based on the subtraction result.In this example, there are four condition status indications 40: anegative flag N indicating whether a previous processing result wasnegative; a zero flag Z indicating whether a result of a previousprocessing operation was zero; a carry flag C indicating whether aprevious processing operation involved a carry out from the mostsignificant bit of the result; and an overflow flag V which is set if aprocessing operation produces a signed result with an overflow from thesecond most significant bit to the most significant bit (where the mostsignificant bit represents the sign bit indicating the sign of theresult).

As shown in the table in the lower part of FIG. 3, a number of conditioncodes may be assigned corresponding to various sets of values for thecondition status indications. The meaning of each condition code isindicated in the table together with the corresponding flag values ofthe condition status indications 40. A conditional instruction mayspecify a parameter indicating a particular test condition (e.g. EQ, NE,etc.) to be satisfied in order for a corresponding conditional operationto be carried out. The test condition parameter of the conditionalinstruction may define one of the condition codes specified in FIG. 3.

As shown in FIG. 4, the processor core 2 shown in FIG. 1 may be one ofmultiple cores 2 in a multi-processor system. The processor cores 2 maybe connected via an interconnect 50 which may handle communicationbetween the cores and access to the memory system 16. In some cases theinterconnect 50 may be a coherent interconnect which also managescoherency between respective caches 10, 14 of the different cores 2.

In some examples at least two of the cores 2 may include the hardwaretransactional memory resources 20 shown in FIG. 1. In some cases all ofthe cores 2 may have such hardware transactional memory resources 20.However this is not essential and in some cases there may also be someprocessor cores which are not capable of executing transactions. In theexample of FIG. 4, each of the individual cores 2 is shown as having thetransactional memory support circuitry 20 within the micro-architectureof the individual processor core 2, but this is not essential. In somecases some transactional memory resources can be shared betweenprocessor cores. For example some common storage for capturingrestoration state or tracking addresses could be provided, which can beshared for use between multiple processor cores.

FIG. 5 schematically illustrates the use of transactions executing onmultiple processor cores 2 for carrying out thread level speculation(TLS). TLS is a technique for speeding up execution of a program loopwhich is expected to be free of dependencies between iterations atruntime, but where the iterations cannot be proven to be independent atcompile time. For example, such program loops may include address accesspatterns that depend on the data which is input to the program, or makeindirect accesses to memory that cannot be disambiguated by the staticanalysis available to the compiler. Hence, while often such loops may beable to execute with multiple iterations performed in parallel,sometimes conflicts could arise between the addresses accessed bydifferent iterations and if so then this may need to be detected toprevent a later iteration using the incorrect value when it is updatedby an earlier iteration in the loop after it has already been read bythe later iteration.

The transactional memory resources 20 discussed above can be useful forcarrying out address conflict checking. Hence, as shown in FIG. 5, for agiven loop, each iteration may be allocated to a particular thread ofprocessing performed on one of the processor cores 2, where theoperations of the iteration are performed within a transaction 60performed in the corresponding thread of processing. For example in FIG.5 the operations corresponding to iteration 0 of the loop have beenallocated to a transaction 60-0 performed in a thread on core 0, theoperations corresponding to iteration 1 have been allocated to atransaction 60-1 performed in a thread on core 1 and so on for the otheriterations of the loop. In this example there are four processor coressupporting transactional memory and so four iterations can be processedin parallel.

The transaction corresponding to a given loop iteration cannot becommitted until the preceding iteration of the loop has also had itstransaction committed, so that if a conflict is detected between theaddresses accessed by one iteration and the addresses accessed byanother iteration then the later iteration can be aborted and restartedonce the earlier iteration having the conflicting address has committed.This ensures that the overall result is the same as if all of theiterations have been executed one by one in a sequential manner. To helptrack which iterations have been committed, a loop iteration commitvariable 70 is stored in the memory system 16 and each of thetransactions 60 includes some instructions for checking the currentvalue of the loop iteration commit variable 70 to determine whether thetransactions for the required earlier iterations have been committed,and hence whether the current transaction can also commit. For exampleeach transaction may include a while loop which loops until the loopiteration commit variable indicates that the relevant precedingiteration has committed, and then allows the transaction to be committedby executing a transaction end instruction. The particular form in whichthe loop iteration commit variable 70 is represented can vary. Forexample the loop iteration commit variable could in some cases indicatethe iteration number of the most recently committed iteration. In otheralternatives, the loop iteration commit variable 70 may indicate theiteration number of the next iteration to be committed. In general theloop iteration commit variable 70 may take any value which enables thecode to deduce which iteration is the next one to commit.

Hence, each of the transactions 60 includes (towards the end of thetransaction code) some instructions for checking the loop iterationcommit variable to determine whether it is possible to commit thecurrent transaction. In the example of FIG. 5, the transactions 60corresponding to iterations 0 to 5 execute without any conflict beingdetected against the addresses accessed by earlier transactions so theseare able to commit without delay. That is, the transactions 60-0 to 60-5for iterations 0 to 5 accessed addresses which were independent fromeach other.

However, when executing the transaction 60-6 for iteration 6 a conflictis detected between an address accessed in iteration 6 and an addressaccessed in iteration 5. This triggers the abort of the transaction 60-6corresponding to iteration 6. The processor core 2 executing thetransaction 60-6 then retries a transaction 60-6′ corresponding to loopiteration 6 once the transaction 60-5 for loop iteration 5 has alreadycommitted.

However, as a consequence of the transaction 60-6 for loop iteration 6being aborted and retried, this then delays the commit for thetransactions corresponding to subsequent iterations 7, 8 and 9, as theymust wait for loop iteration 6 to commit before they can commit. Hence,even if the actual processing operations during transaction 60-7, 60-8and 60-9 are accessing addresses which are independent of the addressesaccessed in any other iteration, these transactions are prevented fromcommitting until transaction 60-6′ has finished.

Hence in general, to support use of transactions for implementing TLS, amechanism is needed for allowing different transactions to access ashared variable 70 for tracking the commitment of respected iterationsof a program loop. It is desirable that the load from memory foraccessing the shared loop iteration commit variable 70 does not triggerthe abort of any other transaction which reads/writes to the sameaddress, because otherwise each of the iterations of the program loopwould have to be performed sequentially one by one, which wouldeliminate the very advantage of using TLS in the first place toparallelise different iterations of the same program loop.

One approach for supporting such non-aborted access to a shared variablefor multiple transactions could be to provide an instruction setarchitecture which allows a transaction to be suspended part way throughthe transaction without aborting the transaction, so that during thetime when a transaction is suspended a number of memory access can bemade which result in the corresponding addresses being accessed frommemory without adding those addresses to the transaction's working setof addresses.

In such an architecture, if during the period of suspension otherthreads have accessed one of the addresses which were added to theworking set of addresses prior to the suspension of the currenttransaction, then the transaction is aborted on resumption of thetransaction following the period of suspension. However the addressesaccessed by the suspended transaction itself during the suspension arenot added to the working set of addresses. This instruction setarchitecture functionality could be used to support TLS by suspending athread just before it needs to check the shared loop iteration commitvariable so that the access to that variable will not be treated as anaddress to be tracked in the working set of addresses. However, aproblem with this approach is that providing the microarchitecturalsupport for suspending and resuming transactions mid-transaction isrelatively expensive in terms of the additional hardware logic required.This is a heavyweight approach which may be unlikely to be adopted insome architectures.

Another approach for enabling a shared variable to be checked withouttracking that address in the working set of addresses for a transactionmay be to provide a non-transactional load instruction which enables ageneral load access to a specified memory address, so that the datavalue read from the address location is returned to the processor coreand placed in the architectural registers 6 of the processor core 2, butwithout the corresponding memory address being added to the working setof addresses tracked by the address tracking circuitry 24. This approachmay be undesirable, because providing the general ability for code toexecute a load to an arbitrary address without that address beingtracked in the working set of addresses for a transaction may lead toinappropriate use of transactions for operations which are not reallyintended to be processed in a transactional manner. This could lead toproblems as it may result in transactions in practice remaining pendingfor much longer within program code written by a programmer or acompiler, which may place stress on the transactional resources 20available. By not supporting non-transactional loads, theprogrammer/compiler is forced to consider more carefully whichoperations really need to be bounded by transaction start/endinstructions. Also, it is also more likely that a programmer or compilermay inadvertently use a non-transactional load for accessing a variablewhich really should be accessed transactionally so that its address isadded to the working set of addresses so that conflicts can be detectedand transactions aborted if necessary. Hence, it may generallyundesirable to provide general architectural support for loads to memorywithin a transaction that do not result in the corresponding addressbeing tracked in the working set of addresses for the transaction.

FIG. 6 shows a transactional compare-and-discard instruction which canaddress these problems. The instruction decoder 8 recognises aparticular type of instruction encoding (instruction of code) asrepresenting the transactional compare-and-discard instruction. Inresponse to detecting such an instruction, the decoder 8 generatescontrol signals for controlling the processing logic 4 to load a targetdata value 80 from the memory system 14, 16 from a location identifiedby a target address 82 which is specified by parameters of thetransactional compare-and-discard instruction, and to compare the targetdata value 80 with a compare value 84 which is specified within a sourceregister 86 of the architectural register file 6. The transactionalcompare-and-discard instruction identifies this source register 86within the encoding of the instruction. The target address 82 could bean absolute address or a relative address identified relative to theaddress of the transactional compare-and-discard instruction itself, andcould be identified based on an immediate value or values in one or moreregisters. Based on the result of comparing the target data value 80with the compare value 84, the processing logic 4 sets the conditionstatus indications 40 of the status register 7 to values depending onthe result of the comparison. The processing logic 4 then discards thetarget data value 80 without writing the target data value 80 to any ofthe architectural registers 6 of the processor core 2 and without addingthe target address 82 to the working set (read set) of addresses trackedby the address tracking circuitry 24. Hence, the code executing thetransactional compare-and-discard instruction does not gain access tothe actual value of the target data value 80, but merely sees theresulting condition flags 40 which were set based on the comparison withthe compare value 84. For example, the condition flags 40 may indicatewhether the compare value 84 was greater than or less than or equal tothe target data value 80.

Hence, when using transactions to implement TLS as shown in FIG. 5, thetransactional compare-and-drop instruction can be used towards the endof each transaction to check the loop iteration commit variable 70 andcompare it against a compare value specified in a register whichindicates (directly or indirectly) the iteration number of theprocessing being performed by the current transaction. This allows thetransaction to determine whether or not it is ready to commit or shouldwait until other transactions have committed. Since the compare anddiscard instruction does not provide general access to the target datavalue 80 itself, it is less likely that this transaction could bemisused by programmers or compilers, and the architectural support forthe compare-and-discard instruction means that it is not necessary tosupport the ability to suspend transactions midway through, which cangreatly reduce the microarchitectural overhead of implementing theinstruction set architecture.

FIG. 7 illustrates a flow diagram showing a method of processingtransactions. At step 100 a transaction start instruction is decoded andexecuted. In response, at step 102 the restoration state storage 28captures a current snapshot of the architectural state in thearchitectural registers 6, as the restoration state to be maintained forthe transaction. It will be appreciated that while in some cases thiscould result in the captured architectural state being written toseparate registers, other implementations may use a physical registerfile for the architectural registers 6 which has a greater number ofregisters than the number of registers supported in the instruction setarchitecture, with register renaming being used to remap whichparticular physical register is considered to store the data value for aparticular architectural register required by the architecture. In sucha system, register renaming could be used to change the mapping fromarchitectural registers to physical registers on encountering atransaction start instruction, so that previously captured checkpointsof architectural state could effectively be maintained within the samephysical register file as the current architectural state itself, whichcan speed up restoration of state if necessary. In this case, thecapture of restoration state could be done by changing the registermappings so may not need any actual transfer of data to/from physicalregisters.

At step 104, speculative execution of instructions following thetransaction start instruction begins. While instructions are executedspeculatively within the transaction, results of some speculativeinstructions may be allocated to the speculative result storagecircuitry 22 (e.g. results of store instructions for storing data tomemory). Addresses accessed by the speculatively executed instructionsmay be added to the address tracking structure 24, and while thetransaction remains pending accesses by other threads to the working setof addresses maintained by the address tracking structure 24 for thetransaction may be monitored.

At step 106 the conflict detection circuitry detects whether an abortevent has occurred. For example the abort event could be another threadaccessing one of the working set of addresses tracked by the addresstracking structure 24, the occurrence of an interrupt or exception, theexecution of an instruction type which is not allowed to be executedwithin a transaction, or the resources available for address tracking 24or speculative result storage 22 being fully utilised so that it is nolonger possible to continue to safely execute the transaction (as someadditional addresses or speculative results which may need to be storedmay not be able to be tracked anymore). It will be appreciated thatother types of abort could also be defined depending on the constraintsof the instruction set architecture. If an abort event occurs then atstep 108 the transaction is aborted and the restoration state stored inthe restoration state storage 28 is restored to the architecturalregisters 6 which represent the current architectural state of thesystem. Processing may then resume from the earlier point of executingrepresented by the restored architectural state. In some cases, onaborting a transaction, the microarchitecture may provide a hint whichindicates the reason why the transaction is aborted, which could be usedby an exception handler in software to determine whether it is worthattempting to execute the required operations as a transaction again, orwhether it is preferable to retreat to executing a fallback path (whichdoes not use transactions) to execute the corresponding processingoperations.

If no abort event occurs at step 106, then at step 110 it is determinedwhether any transaction end instruction has been decoded and executed.If not then the method loops back to step 106 to await either an abortevent or the execution of a transaction end instruction. It will beappreciated that the speculative execution of instructions and thetracking of the working set of addresses and potential conflictscontinues throughout steps 104 to 110 until either an abort event occursor a transaction end instruction is reached.

When the transaction end instruction is executed then at step 112 anyspeculative results of the transaction are committed to state and thepreviously captured restoration state is discarded or permitted to beoverwritten.

FIG. 8 is a flow diagram showing processing of a transactionalcompare-and-discard instruction as discussed above. At step 120, whileexecuting instructions speculatively within a transaction, theinstruction decoder 8 identifies a transactional compare-and-discardinstruction which specifies a target address and a compare value. Inresponse, the instruction decoder 8 generates control signals forcontrolling the processing logic 4 and load/store unit 12 (which maycollectively be described as processing circuitry) to perform thesubsequent steps of FIG. 8.

At step 122 the load/store unit 12 triggers a load of a target datavalue from a memory location in the cache 14 or memory system 16 whichcorresponds to the target address specified by the transactionalcompare-and-discard instruction. When the target data value is returnedfrom memory, at step 124 the processing logic 4 compares the target datavalue 80 with a compare value 84 obtained from a register specified bythe transactional compare-and-discard instruction. For example thecomparison may involve subtracting one of the target data value and thecompare value from the other. At step 126 the processing logic sets thecondition status flags 40 of the status register 7 depending on a resultof the comparison at step 124. For example the Z flag may be set if thetarget and compare values were equal, the C flag may be set if one ofthe target data value and the compare value was greater than or equal tothe other, and so on. At step 128 the target data value is thendiscarded without adding the target address 82 to the transaction's readset of addresses tracked by the address tracking circuitry 24, andwithout writing the target data value 80 to any of the architecturalregisters 6.

Hence, having executed a transactional compare-and-discard instruction asubsequent conditional instruction such as a conditional branchinstruction can then test the values of the condition status indications40 to determine, depending on the target data value, whether asubsequent transaction end instruction should be executed or whether theprogram flow should loop back to check again whether the target datavalue meets the required condition in order to allow the transaction tocommit. This is very useful for supporting the thread level speculationas shown in FIG. 5.

FIGS. 9 and 10 show examples of bus protocol messages supported by thebus protocol used by the interconnect 50 to manage data access to thememory system 16 and coherency and conflicts between transactions onmultiple processor cores 2. FIG. 9 shows an example of bus protocolmessages triggered when a transaction on core 0 executes a transactionalcompare-and-discard instruction of the type discussed above. Theexecution of the transactional compare-and-discard instruction at core 0triggers issue of a first type of read bus protocol message to theinterconnect 50. The message species an address X which corresponds tothe target address specified by the transactional compare-and-discardinstruction. In response to the first type of read bus protocol message,the interconnect 50 sends a first type of snoop message to other coresto check for coherency status of data cached at those cores.Alternatively, if the interconnect 50 maintains tracking data at leastpartly tracking the data cached at other cores, and can determine basedon that tracking data that the data for address X is not cached by anyother core, then it may not be necessary to send the snoop message. Theinterconnect 50 obtains data corresponding to the target address, whichcould be obtained either from caches at other processor cores 2, or froma system cache within the interconnect, or from the memory system 16.The data is returned to core 0, used for the comparison against thecompare value of the transactional compare-and-discard instruction, andthen discarded without writing the data to an architectural register oradding the address X into the transaction's read set.

At the time when the transactional compare-and-discard instruction isexecuted on core 0, there could be another core (e.g. core 1) which isexecuting a transaction for which address X is specified in thetransaction's write set of addresses (i.e. the transaction on core 0 hasalready requested writing of an updated value to address X—the updatedvalue may be buffered in the speculative result storage 22 of core 1until the transaction is committed). As the data required by core 0 isonly being used for the comparison for the transactionalcompare-and-discard instruction, e.g. for checking of a loop iterationcommit variable 70 expected to be incremented as transactionsimplementing TLS commit, it is not a problem to return out of date datawhich has not yet been updated by the transaction on core 1, since thiswould simply lead to a while loop in the transaction on core 0 spinningfor some additional iterations until the transaction on core 1 commitsand the up to date value is available. In practice, as the writes to theshared loop iteration commit variable 70 would be expected to be nearthe end of a transaction, the period for which the write remainsspeculative at core 1 may be relatively short, so it is unlikely thatthe while loop at core 0 would need to spin for many additional cycles.Hence, to improve performance at core 1, in response to the snoopmessage triggered by the first type of read bus protocol message shownin FIG. 9, it is not necessary to abort the transaction on core 1, eventhough address X specified by the first type of read bus protocolmessage was in the transaction's write set.

In contrast, as shown in FIG. 10, when core 0 executes another type ofload instruction specifying address X, a second type of read busprotocol message is issued to the interconnect 50. The second type ofread message may be distinguished from the first type of read message inany way, e.g. by a message type indicator or by a further parameter ofthe message. In response to the second type of read message, a differenttype of snoop message is sent to other cores compared to in FIG. 9. Whenthe second type of read bus protocol message is sent, then if anothercore (e.g. core 1) is currently executing a transaction with address Xin its write set, then that transaction is aborted to preserve mutualexclusion and ensure that the transaction on core 1 cannot commit awrite to address X after address X has been read by a transaction oncore 0.

In summary, the coherence/bus protocol support on the interconnect canuse the first type of read message shown in FIG. 9 to denote that thevalue returned will only be used in a comparison, as opposed to a moregeneral type of load which loads the value into the architecturalregisters of the core. This means that if core 0 uses a compare anddiscard instruction in transaction 1, and the address is currently intransaction 2′s write set at core 1, and so speculatively modified, theinterconnect can choose to respond with an old value (e.g. from a sharedcache) rather than aborting transaction 2 and responding with the olddata anyway. This can enable performance improvements at both core 0 andcore 1—at core 0 the data may be returned faster if it can be returnedfrom a shared cache with lower access latency, and at core 1 thetransaction can continue unaborted and may reach commit earlier than ifit was aborted and had to be retried later.

FIG. 11 illustrates a simulator implementation that may be used. Whilethe earlier described embodiments implement the present technique interms of apparatus and methods for operating specific processinghardware supporting the techniques concerned, it is also possible toprovide an instruction execution environment in accordance with theembodiments described herein which is implemented through the use of acomputer program. Such computer programs are often referred to assimulators, insofar as they provide a software based implementation of ahardware architecture. Varieties of simulator computer programs includeemulators, virtual machines, models, and binary translators, includingdynamic binary translators. Typically, a simulator implementation mayrun on a host processor 330, optionally running a host operating system320, supporting the simulator program 310. In some arrangements, theremay be multiple layers of simulation between the hardware and theprovided instruction execution environment, and/or multiple distinctinstruction execution environments provided on the same host processor.Historically, powerful processors have been required to providesimulator implementations which execute at a reasonable speed, but suchan approach may be justified in certain circumstances, such as whenthere is a desire to run code native to another processor forcompatibility or re-use reasons. For example, the simulatorimplementation may provide an instruction execution environment withadditional functionality which is not supported by the host processorhardware, or provide an instruction execution environment typicallyassociated with a different hardware architecture. An overview ofsimulation is given in “Some Efficient Architecture SimulationTechniques”, Robert Bedichek, Winter 1990 USENIX Conference, Pages53-63.

To the extent that embodiments have previously been described withreference to particular hardware constructs or features, in a simulatedembodiment, equivalent functionality may be provided by suitablesoftware constructs or features. For example, particular circuitry maybe implemented in a simulated embodiment as computer program logic.Similarly, memory hardware, such as a register or cache, may beimplemented in a simulated embodiment as a software data structure. Inarrangements where one or more of the hardware elements referenced inthe previously described embodiments are present on the host hardware(for example, host processor 330), some simulated embodiments may makeuse of the host hardware, where suitable.

The simulator program 310 may be stored on a computer-readable storagemedium (which may be a non-transitory medium), and provides a programinterface (instruction execution environment) to the target code 300(which may include applications, operating systems and a hypervisor)which is the same as the application program interface of the hardwarearchitecture being modelled by the simulator program 310. Thus, theprogram instructions of the target code 300, including the predeterminedtype of load instruction and load/store-exclusive instructions describedabove, may be executed from within the instruction execution environmentusing the simulator program 310, so that a host computer 330 which doesnot actually have the hardware features of the apparatus 2 discussedabove can emulate these features. The simulator program 310 may includeprocessing program logic 312, transactional memory program logic 314 andconflict detection program logic 316 providing functionalitycorresponding to the processing logic 4, hardware transactional memoryresources 20 and conflict detection circuitry 26 respectively.

In the present application, the words “configured to . . . ” are used tomean that an element of an apparatus has a configuration able to carryout the defined operation. In this context, a “configuration” means anarrangement or manner of interconnection of hardware or software. Forexample, the apparatus may have dedicated hardware which provides thedefined operation, or a processor or other processing device may beprogrammed to perform the function. “Configured to” does not imply thatthe apparatus element needs to be changed in any way in order to providethe defined operation.

Although illustrative embodiments of the invention have been describedin detail herein with reference to the accompanying drawings, it is tobe understood that the invention is not limited to those preciseembodiments, and that various changes and modifications can be effectedtherein by one skilled in the art without departing from the scope andspirit of the invention as defined by the appended claims.

1. An apparatus comprising: processing circuitry to process threads ofdata processing; and transactional memory support circuitry to supportexecution of a transaction within a thread processed by the processingcircuitry, the transaction comprising instructions of the threadexecuted speculatively between a transaction start instruction and atransaction end instruction, for which the processing circuitry isconfigured to prevent commitment of results of the speculativelyexecuted instructions until the transaction end instruction is reached,the transactional memory support circuitry comprising conflict detectioncircuitry to trigger an abort of the transaction in response todetecting a conflicting access from another thread to one of a workingset of addresses tracked for the transaction; in which: in response to atransactional compare-and-discard instruction executed within a giventransaction, the transactional compare-and-discard instructionspecifying a target address and a compare value, the processingcircuitry is configured to: load a target data value from a memorylocation corresponding to the target address; set at least one conditionstatus indication depending on a result of comparing the target datavalue and the compare value; and discard the target data value withoutadding the target address to the working set of addresses for the giventransaction.
 2. The apparatus according to claim 1, in which thetransactional compare-and-discard instruction specifies a sourceregister storing the compare value.
 3. The apparatus according to claim1, in which in response to the transactional compare-and-discardinstruction, the processing circuitry is configured to discard thetarget data value without writing the target data value to anarchitectural register of the processing circuitry.
 4. The apparatusaccording to claim 1, in which in response to a conditional instructionspecifying a test condition, the processing circuitry is configured toperform a processing operation conditional on said at least onecondition status indication meeting said test condition.
 5. Theapparatus according to claim 1, in which the transactional memorysupport circuitry also comprises speculative result storage circuitry tostore results of speculatively executed instructions for at least onetransaction.
 6. The apparatus according to claim 1, in which thetransactional memory support circuitry also comprises restoration statestorage circuitry to store state captured in response to the transactionstart instruction to be restored on aborting the transaction.
 7. Theapparatus according to claim 1, in which in response to thetransactional compare-and-discard instruction, the processing circuitryis configured to trigger issue of a first bus protocol message forrequesting the load of the target data value from a memory system; thefirst bus protocol message comprising an indication which distinguishesthe bus protocol message from a second bus protocol message issued forother types of instruction requiring a load of a data value from memory.8. The apparatus according to claim 7, comprising a further processingelement comprising the transactional memory support circuitry; in which:in response to receipt of the first bus protocol message or a furtherbus protocol message triggered by said first bus protocol message, whenthe target address is within a write set of addresses tracked for atransaction being processed at the further processing element, thefurther processing element is configured to permit continued unabortedprocessing of the transaction at the further processing element.
 9. Adata processing method comprising: executing a transaction comprisinginstructions of a thread executed speculatively between a transactionstart instruction and a transaction end instruction, for which theprocessing circuitry is configured to prevent commitment of results ofthe speculatively executed instructions until the transaction endinstruction is reached, detecting conflicting accesses from anotherthread to one of a working set of addresses tracked for the transaction,and when a conflicting access is detected, aborting the transaction; andin response to a transactional compare-and-discard instructionspecifying a target address and a compare value, which is executedwithin the transaction: loading a target data value from a memorylocation corresponding to the target address; setting at least onecondition status indication depending on a result of comparing thetarget data value and the compare value; and discarding the target datavalue without adding the target address to the working set of addressesfor the given transaction.
 10. The data processing method according toclaim 9, comprising performing thread level speculation to execute aplurality of threads of processing, each thread corresponding to arespective one of a plurality of iterations of a program loop andcomprising at least one transaction.
 11. The data processing methodaccording to claim 10, in which the transactional compare-and-discardinstruction specifies as the target address an address of a loopiteration commit variable for tracking progress in committingtransactions for the plurality of iterations of the program loop. 12.The data processing method of claim 9, comprising executing one or moreinstructions to determine whether to abort the transaction in dependenceon whether the at least one condition status indication satisfies a testcondition.
 13. A computer program for controlling a host data processingapparatus to provide an instruction execution environment for executionof threads of data processing; the computer program comprising:processing program logic to process threads of data processing; andtransactional memory program logic to support execution of a transactionwithin a thread processed by the processing program logic, thetransaction comprising instructions of the thread executed speculativelybetween a transaction start instruction and a transaction endinstruction, for which the processing program logic is configured toprevent commitment of results of the speculatively executed instructionsuntil the transaction end instruction is reached, the transaction memoryprogram logic comprising conflict detection program logic to trigger anabort of the transaction in response to detecting a conflicting accessfrom another thread to one of a working set of addresses tracked for thetransaction; in which: in response to a transactionalcompare-and-discard instruction executed within a given transaction, thetransactional compare-and-discard instruction specifying a targetaddress and a compare value, the processing program logic is configuredto: load a target data value from a memory location corresponding to thetarget address; set at least one condition status indication dependingon a result of comparing the target data value and the compare value;and discard the target data value without adding the target address tothe working set of addresses for the given transaction.
 14. A storagemedium storing the computer program of claim 13.